const request = require('../httprequest.js')

/**
 * 获取banner列表
 * @returns {Promise | Promise<unknown>}
 */
function getBanner () {
  return request.get(`banner/json`)
}

/**
 *获取置顶文章列表
 * @returns {Promise | Promise<unknown>}
 */
function getTopArticles () {
  return request.get(`article/top/json`)
}

/**
 * 获取首页文章列表
 * @param page
 * @returns {Promise | Promise<unknown>}
 */
function getHotsArticles (page) {
  return request.get(`article/list/${page}/json`)
}

/**
 * 添加收藏
 * @param title
 * @param link
 * @returns {Promise<unknown>}
 */
function addCollect (articleId) {
  return request.post(`lg/collect/${articleId}/json`)
}

/**
 * 取消收藏
 * @param articleId
 * @returns {Promise<unknown>}
 */
function unCollect (articleId) {
  return request.post(`lg/uncollect_originId/${articleId}/json`)
}


module.exports = {
  getBanner,
  getTopArticles,
  getHotsArticles,
  addCollect,
  unCollect
}
